/*
               File: PrcGetParameterValue
        Description: Prc Get Parameter Value
             Author: GeneXus C# Generator version 10_2_5-78484
       Generated on: 6/6/2014 9:52:43.8
       Program type: Callable routine
          Main DBMS: sqlserver
*/
using System;
using System.Collections;
using GeneXus.Utils;
using GeneXus.Resources;
using GeneXus.Application;
using GeneXus.Metadata;
using System.Data;
using System.Data.SqlClient;
using GeneXus.Data;
using com.genexus;
using GeneXus.Data.ADO;
using GeneXus.Data.NTier;
using GeneXus.Data.NTier.ADO;
using System.Runtime.Remoting;
using GeneXus.WebControls;
using GeneXus.Http;
using GeneXus.Procedure;
using GeneXus.XML;
using GeneXus.Search;
using GeneXus.Encryption;
using GeneXus.Http.Client;
using System.Threading;
using System.Xml.Serialization;
using System.Data.SqlTypes;
using System.ServiceModel;
using System.Runtime.Serialization;
namespace GeneXus.Programs {
   public class prcgetparametervalue : GXProcedure
   {
      public prcgetparametervalue( )
      {
         context = new GxContext(  );
         DataStoreUtil.LoadDataStores( context);
         dsDefault = context.GetDataStore("Default");
         IsMain = true;
         context.SetDefaultTheme("GeneXusXEv2");
      }

      public prcgetparametervalue( IGxContext context )
      {
         this.context = context;
         IsMain = false;
         dsDefault = context.GetDataStore("Default");
      }

      public void release( )
      {
      }

      public void execute( long aP0_ParameterId ,
                           out String aP1_ParameterValue )
      {
         this.AV8ParameterId = aP0_ParameterId;
         this.AV9ParameterValue = "" ;
         initialize();
         executePrivate();
         aP1_ParameterValue=this.AV9ParameterValue;
      }

      public String executeUdp( long aP0_ParameterId )
      {
         this.AV8ParameterId = aP0_ParameterId;
         this.AV9ParameterValue = "" ;
         initialize();
         executePrivate();
         aP1_ParameterValue=this.AV9ParameterValue;
         return AV9ParameterValue ;
      }

      public void executeSubmit( long aP0_ParameterId ,
                                 out String aP1_ParameterValue )
      {
         prcgetparametervalue objprcgetparametervalue;
         objprcgetparametervalue = new prcgetparametervalue();
         objprcgetparametervalue.AV8ParameterId = aP0_ParameterId;
         objprcgetparametervalue.AV9ParameterValue = "" ;
         objprcgetparametervalue.context.SetSubmitInitialConfig(context);
         objprcgetparametervalue.initialize();
         ThreadPool.QueueUserWorkItem( new WaitCallback( executePrivateCatch ),objprcgetparametervalue);
         aP1_ParameterValue=this.AV9ParameterValue;
      }

      void executePrivateCatch( object stateInfo )
      {
         try
         {
            ((prcgetparametervalue)stateInfo).executePrivate();
         }
         catch ( Exception e )
         {
            GXUtil.SaveToEventLog( "Design", e);
            throw e ;
         }
      }

      void executePrivate( )
      {
         /* GeneXus formulas */
         /* Output device settings */
         /* Using cursor P00092 */
         pr_default.execute(0, new Object[] {AV8ParameterId});
         while ( (pr_default.getStatus(0) != 101) )
         {
            A51ParameterId = P00092_A51ParameterId[0];
            A53ParameterValue = P00092_A53ParameterValue[0];
            AV9ParameterValue = A53ParameterValue;
            /* Exiting from a For First loop. */
            if (true) break;
         }
         pr_default.close(0);
         this.cleanup();
      }

      public void cleanup( )
      {
         CloseOpenCursors();
         if ( IsMain )
         {
            context.CloseConnections() ;
         }
         exitApplication();
      }

      protected void CloseOpenCursors( )
      {
      }

      public override void initialize( )
      {
         scmdbuf = "";
         P00092_A51ParameterId = new long[1] ;
         P00092_A53ParameterValue = new String[] {""} ;
         A53ParameterValue = "";
         pr_default = new DataStoreProvider(context, new GeneXus.Programs.prcgetparametervalue__default(),
            new Object[][] {
                new Object[] {
               P00092_A51ParameterId, P00092_A53ParameterValue
               }
            }
         );
         /* GeneXus formulas. */
         context.Gx_err = 0;
      }

      private long AV8ParameterId ;
      private long A51ParameterId ;
      private String scmdbuf ;
      private String AV9ParameterValue ;
      private String A53ParameterValue ;
      private IGxDataStore dsDefault ;
      private IDataStoreProvider pr_default ;
      private long[] P00092_A51ParameterId ;
      private String[] P00092_A53ParameterValue ;
      private String aP1_ParameterValue ;
   }

   public class prcgetparametervalue__default : DataStoreHelperBase, IDataStoreHelper
   {
      public ICursor[] getCursors( )
      {
         cursorDefinitions();
         return new Cursor[] {
          new ForEachCursor(def[0])
       };
    }

    private static CursorDef[] def;
    private void cursorDefinitions( )
    {
       if ( def == null )
       {
          Object[] prmP00092 ;
          prmP00092 = new Object[] {
          new Object[] {"@AV8ParameterId",SqlDbType.Decimal,15,0}
          } ;
          def= new CursorDef[] {
              new CursorDef("P00092", "SELECT [ParameterId], [ParameterValue] FROM [TBLParameter] WITH (NOLOCK) WHERE [ParameterId] = @AV8ParameterId ORDER BY [ParameterId] ",false, GxErrorMask.GX_NOMASK | GxErrorMask.GX_MASKLOOPLOCK, false, this,prmP00092,1,0,false,true )
          };
       }
    }

    public void getResults( int cursor ,
                            IFieldGetter rslt ,
                            Object[] buf )
    {
       switch ( cursor )
       {
             case 0 :
                ((long[]) buf[0])[0] = rslt.getLong(1) ;
                ((String[]) buf[1])[0] = rslt.getLongVarchar(2) ;
                break;
       }
    }

    public void setParameters( int cursor ,
                               IFieldSetter stmt ,
                               Object[] parms )
    {
       switch ( cursor )
       {
             case 0 :
                stmt.SetParameter(1, (long)parms[0]);
                break;
       }
    }

 }

}
